//
//  WCNCaseItemTCell.m
//  WCN
//
//  Created by 杨鑫 on 15/6/14.
//  Copyright (c) 2015年 ShanghaiCize Trade And Business Co., Ltd. All rights reserved.
//

#import "WCNCaseItemTCell.h"
//
#import "WCImageManager.h"

@interface WCNCaseItemTCell ()

@property (weak, nonatomic) IBOutlet UIImageView *imageView1;
@property (weak, nonatomic) IBOutlet UIImageView *imageView2;
@property (weak, nonatomic) IBOutlet UIImageView *imageView3;
@property (weak, nonatomic) IBOutlet UIImageView *imageView4;
@property (weak, nonatomic) IBOutlet UIImageView *imageView5;

@end

@implementation WCNCaseItemTCell

- (void)awakeFromNib
{
    [super awakeFromNib];
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (void)setImgs:(NSArray *)imgs
{
    _imgs = imgs;
    self.imageView1.image = nil;
    self.imageView2.image = nil;
    self.imageView3.image = nil;
    self.imageView4.image = nil;
    self.imageView5.image = nil;
    
    UIImageView *imageView;
    for (int i=1; i<=imgs.count; i++) {
        imageView = [self valueForKey:[NSString stringWithFormat:@"imageView%d", i]];
        
        NSString *imgUrl = imgs[i-1];
        UIImage *image = [[WCImageManager sharedMg] image:imgUrl type:WCImageTypeImage size:WCImageSizeSmall cache:YES];
        if (image) {
            imageView.image = image;
        } else {
            [[WCImageManager sharedMg] downloadImage:imgUrl type:WCImageTypeImage size:WCImageSizeSmall cache:YES success:^(UIImage *image, NSString *stringId){
                if ([stringId isEqualToString:self.imgs[i-1]]) {
                    imageView.image = image;
                }
            } failure:nil];
        }
    }
}

@end
